﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace PepsiCo.Intranet.WebParts.ContactInfomation
{
    [ToolboxItemAttribute(false)]
    public class ContactInfomation : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/PepsiCo.Intranet.WebParts/ContactInfomation/ContactInfomationUserControl.ascx";

        private string pageSize = "5";
        [WebBrowsable(true),
        Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Number of displaying items"),
        WebDescription("")]
        public string PageSize
        {
            get { return pageSize; }
            set { pageSize = value; }
        }

        private int pictureWidth = 96;
        [WebBrowsable(true),
        Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Main picture's width (default: 96)"),
        WebDescription("")]
        public int PictureWidth
        {
            get { return pictureWidth; }
            set { pictureWidth = value; }
        }

        protected override void CreateChildControls()
        {
            ContactInfomationUserControl control = Page.LoadControl(_ascxPath) as ContactInfomationUserControl;
            if (control != null)
                control.WebPart = this;
            Controls.Add(control);
        }
    }
}
